package goover.unit03;

import java.util.Arrays;

public class ArraysDemo01 {
    public static  void main(String[] args){
        int[] arr = {3,16,8,2,16,33,21};
        System.out.print("排序前：");
        printArray(arr);
        Arrays.sort(arr);
        System.out.print("排序后：");
        printArray(arr);
        int index = Arrays.binarySearch(arr,16);
        System.out.println(index);
        int[] arr2 = Arrays.copyOfRange(arr,0,3);
        printArray(arr2);
        Arrays.fill(arr2,0);
        printArray(arr2);
    }
    public static void printArray(int[] arr){
        for(int i = 0;i < arr.length;i++){
            if(i == arr.length - 1){
                System.out.println(arr[i]);
            }else {
                System.out.print(arr[i] + ",");
            }
        }
    }
}
